﻿using System;

namespace ch05.binary
{
    public enum ValType
    {
        ValTypeI32 = 0x7F, // i32
        ValTypeI64 = 0x7E, // i64
        ValTypeF32 = 0x7D, // f32
        ValTypeF64 = 0x7C // f64
    }

    public enum BlockType
    {
        BlockTypeI32 = -1, // ()->(i32)
        BlockTypeI64 = -2, // ()->(i64)
        BlockTypeF32 = -3, // ()->(f32)
        BlockTypeF64 = -4, // ()->(f64)
        BlockTypeEmpty = -64 // ()->()
    }

    public static class Types
    {
        internal static string ValTypeToStr(ValType vt)
        {
            return vt switch
            {
                ValType.ValTypeI32 => "i32",
                ValType.ValTypeI64 => "i64",
                ValType.ValTypeF32 => "f32",
                ValType.ValTypeF64 => "f64",
                _ => throw new Exception("invalid valtype: " + vt)
            };
        }
    }
}